package com.sun.alen.controller;


import com.sun.alen.entity.Result;
import com.sun.alen.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/upload")
@Slf4j
public class UploadController {

    @Autowired
    private AliOSSUtils aliOSSUtils;
    @PostMapping
    public Result handleUpload(MultipartFile file) throws Exception {
        log.info("-------------");
        log.info("{}",file);
        log.info("-------------");
        String fileName=aliOSSUtils.upload(file);
        log.info("-------------");
        log.info("{}",fileName);
        log.info("-------------");
        return Result.success(fileName);
    }
}
